//
//  ViewController.m
//  StockpdfReading
//
//  Created by mac on 2017/6/12.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//



// viper   mvcs   胖瘦model



#import "ViewController.h"
#import "ReaderViewController.h"



@interface ViewController ()<ReaderViewControllerDelegate>

@property (nonatomic,strong) NSString *filepath;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}














-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    NSString *phrase = nil; // Document password (for unlocking most encrypted PDF files)
    
//    NSArray *pdfs = [[NSBundle mainBundle] pathsForResourcesOfType:@"pdf" inDirectory:nil];
//    
//    NSString *filePath = [pdfs firstObject]; assert(filePath != nil); // Path to first PDF file
    
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:self.filepath password:phrase];
    
    if (document != nil) // Must have a valid ReaderDocument object in order to proceed with things
    {
        ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
        readerViewController.delegate = self; // Set the ReaderViewController delegate to self
        readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentViewController:readerViewController animated:YES completion:NULL];

    }
    else
    {
//        NSLog(@"%s [ReaderDocument withDocumentFilePath:'%@' password:'%@'] failed.", __FUNCTION__, filePath, phrase);
    }

    
}



#pragma mark - ReaderViewControllerDelegate methods

- (void)dismissReaderViewController:(ReaderViewController *)viewController{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
